const mongoose = require('mongoose')
const Schema = mongoose.Schema
const DisscussionSchemaConfig = {
  versionKey: false,
  timestamps: {
    createdAt: 'created_at',
    updatedAt: false
  }
}

const DisscussionSchema = new Schema({
  team: { type: Schema.Types.ObjectId, ref: 'Team' },
  originator: { type: Schema.Types.ObjectId, ref: 'User' },
  title: String,
  description: String,
  labels: [{ type: Schema.Types.ObjectId, ref: 'Interest' }],
  answers: [{
    replier: { type: Schema.Types.ObjectId, ref: 'User' },
    content: String,
    created_at: { type: Date, default: Date.now },
    thumb: { type: Number, min: 0, default: 0 }
  }]
}, DisscussionSchemaConfig)

exports = module.exports = DisscussionSchema
